const express = require("express");
const path = require("path")
const app = express();


//静态资源暴露
app.use("/upload",express.static(path.resolve(__dirname,"upload")))

//引入数据库连接文件
require("./db")

//引入外部路由
const addAdminRoute = require("./routers/addAdmin");
const addAdminList = require("./routers/addminList");
const deleteAdmin = require("./routers/deleteAdmin");
const loginRoute = require("./routers/login")
const isLogin = require("./routers/isLogin")
const logout = require("./routers/logout")
const addAdv = require("./routers/addAdv")
const advList = require("./routers/advList")
const deleteAdv = require("./routers/deleteAdv")
const getUpdateAdv = require("./routers/getUpdateAdv")
const updateAdv = require("./routers/updateAdv")


//中间件
app.use(express.json())
app.use(express.urlencoded())

//使用相关路由路由
app.use(addAdminRoute)
app.use(addAdminList)
app.use(deleteAdmin)
app.use(loginRoute)
app.use(isLogin)
app.use(logout)
app.use(addAdv)
app.use(advList)
app.use(deleteAdv)
app.use(getUpdateAdv)
app.use(updateAdv)

app.listen(8080, () => {
    console.log("服务器启动成功,请访问 http://127.0.0.1:8080");
})